package torres.item.interactive;

import java.util.List;

import torres.entity.Entity;
import torres.entity.Occupation;

/**
 * @author Torres
 * A special kind of item that can be disabled by a Sneak.
 */
@SuppressWarnings("serial")
public class TrapItem extends InteractiveItem {

	/**
	 * Creates a new TrapItem with the specified name and Interactions.
	 * @param name The name of the TrapItem.
	 * @param intList The Interactions to be performed when this trap is sprung.
	 */
	public TrapItem(String name, List<Interaction> intList) {
		super(name, intList);
	}
	
	/**
	 * Creates a new TrapItem which is a copy of the specified TrapItem.
	 * @param item The TrapItem to be copied.
	 */
	public TrapItem(TrapItem item) {
		this(item.getName(), item.getInteractions());
	}
	
	/** 
	 * Tests to see if this item is a trap.
	 * @return True
	 */
	public boolean isTrap() {
		return true;
	}
	
	/**
	 * Triggers the effect of an Entity walking on this item.
	 * @param e The Entity that is walking on this item
	 */
	public void onTouch(Entity e) {
		if(e.getOccupation().getJob() != Occupation.Job.SNEAK) 
			if(this.getInteractions() != null)
				for(Interaction i : this.getInteractions()) 
					i.use(e);	
	}
}
